package com.example.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class Btns extends AppCompatActivity implements View.OnClickListener {

    private Button btn_Java;
    private Button button_python;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_btns);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

//        通过匿名内部类实现：点击事件
        btn_Java = findViewById(R.id.button_Java);
        btn_Java.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               Toast.makeText(getApplicationContext(),"HELLO Java",Toast.LENGTH_LONG).show();

            }
        });
//第二种 获取第二个按钮
        button_python = findViewById(R.id.Python);
        button_python.setOnClickListener(this);



    }

    @Override
    public void onClick(View v) {
        Toast.makeText(getApplicationContext(),"HELLO Python",Toast.LENGTH_LONG).show();

    }
    public void hello(View view){
        Toast.makeText(getApplicationContext(),"HELLO Android",Toast.LENGTH_LONG).show();


    }
}